package com.ydd.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ydd.dto.UserRegDTO;
import com.ydd.entity.YddUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hgz
 * @since 2023-05-30
 */
@Mapper
public interface YddUserMapper extends BaseMapper<YddUser> {

    @Select("select * from ydd_user order by id desc limit 7")
    List<YddUser> getNewUserNum();

    @Select("select count(*) from ydd_user where sex = #{sex}")
    Integer getTotal(Integer sex);

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into ydd_user (mobile, password, username) values (#{mobile}, #{password},#{mobile})")
    void add(YddUser yddUser);

    @Select("select * from ydd_user where mobile = #{mobile}")
    YddUser selectByMobile(String mobile);

    @Select("select * from ydd_user where mobile = #{mobile}")
    YddUser findByMobile(String mobile);
}
